package  rollercoaster.environment.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import rollercoaster.environment.utils.Index;
import rollercoaster.environment.utils.ModelMaker;
import rollercoaster.environment.utils.OBJFileModelReader;
import rollercoaster.environment.utils.ObjFace;
import rollercoaster.commons.Vertex2D;
import  rollercoaster.commons.Vertex3D;

public class ReaderTest {

	
	public static void main(String[] args) {
		
		OBJFileModelReader reader2= new OBJFileModelReader();
		
		//ModelMaker indices= new ModelMaker(reader2);
		
		reader2.setFilepath("scenarios/western/txsphere.obj");
		
		ArrayList<Vertex3D> listVertices = (ArrayList<Vertex3D>) reader2.getVertices();
		ArrayList<Vertex3D> listNormals = (ArrayList<Vertex3D>) reader2.getNormals();
		ArrayList<Vertex2D> textures = reader2.getTexCoord();
		ArrayList<ObjFace> listFaces = (ArrayList<ObjFace>) reader2.getFaces();
		
		
		
		System.out.println("Vertici: \n");
		
		for (Iterator iterator = listVertices.iterator(); iterator.hasNext();) {
			Vertex3D vertex3d = (Vertex3D) iterator.next();
			System.out.println(vertex3d.getX() + " " + vertex3d.getY() + " " + vertex3d.getZ());
		}
		
		System.out.println("textures: \n");
		
		for (Iterator iterator = textures.iterator(); iterator.hasNext();) {
			Vertex2D vertex2d = (Vertex2D) iterator.next();
			System.out.println(vertex2d.getX() + " " + vertex2d.getY() );
		}
		System.out.println("Normali: \n");

		for (Iterator iterator = listNormals.iterator(); iterator.hasNext();) {
			Vertex3D vertex3d = (Vertex3D) iterator.next();
			System.out.println(vertex3d.getX() + " " + vertex3d.getY() + " " + vertex3d.getZ());
		}
		System.out.println("Facce: \n");

		for (Iterator iterator = listFaces.iterator(); iterator.hasNext();) {
			ObjFace face=(ObjFace) iterator.next();
			for (int i = 0; i < face.getVerteces().length; i++) {
					System.out.println(face.getVerteces()[i]+"/"+face.getTexCoord()[i]+"/"+face.getNormals()[i]);



				//}

			}
		}
		

	}
}
